<?php

namespace app\common\model;

use think\Model;

class User extends Model
{
    protected $table = 'user';

    protected $pk = 'id';

    protected $connection = 'mysql';

    /**
     * 账号获取用户信息
     * @param array $query
     * @return array
     */
    public function getUserData(array $query): array
    {
        return $this->where('account', $query['account'])->findOrEmpty()->toArray();
    }

    /**
     * 主键获取用户信息
     * @param int $pk
     * @return array
     */
    public function getUserByPk(int $pk): array
    {
        return $this->where('id', $pk)->findOrEmpty()->toArray();
    }
}